<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="public/static" /}
    <style>
        .operating{
            display: none;
        }
        .layui-table tr{
            cursor: pointer;
        }
        .layui-table tr:hover > td .operating{
            display: block;
        }
    </style>
</head>
<body>

{include file="public/nav" /}

<div class="layui-fluid" id="root">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                     {eq name="check.BackMenubackMenuOperateoperateadd" value="1"}
                        <button class="layui-btn" onclick="common.openWindow('新增','{:url('BackMenu/backMenuOperate',['operate'=>'add', 'pid'=>0])}','500')" >
                            <i class="layui-icon">&#xe654;</i>新增
                        </button>
                     {/eq}
                </div>
                <div class="layui-card-body layui-table-body">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>标题</th>
                                <th>图标</th>
                                <th>排序</th>
                                <th>路由</th>
                                <th>状态</th>
                                <th width="180">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {volist name="info" id="vo"}
                                <tr cate-id="{$vo.bm_id}" fid="{$vo.bm_pid}" level="{$vo.level}" >
                                    <td><i class="layui-icon x-show" status='true'>|--</i> {$vo.bm_title}</td>
                                    <td><i class="iconfont" style="font-size:1.5rem">{$vo.bm_icon|raw}</i></td>
                                    <td><span class="layui-badge layui-bg-blue">{$vo.bm_sort}</span></td>
                                    <td>{$vo.bm_url}</td>
                                    <td>
                                        {eq name="vo.bm_status" value="1"}
                                            <span class="layui-badge layui-bg-green">启用</span>
                                        {else/}
                                            <span class="layui-badge">禁用</span>
                                        {/eq}
                                    </td>
                                    <td>
                                        <div class="operating">
                                            {eq name="check.BackMenubackMenuOperateoperateadd" value="1"}
                                                <a href="javascript:;" onclick="common.openWindow('新增下级','{:url('BackMenu/backMenuOperate',['operate'=>'edit','pid'=>$vo.bm_id])}','500')" >
                                                    <i class="layui-icon">&#xe654;</i>新增下级
                                                </a>
                                            {/eq}
                                            {eq name="check.BackMenubackMenuOperateoperateedit" value="1"}
                                                <a href="javascript:;" onclick="common.openWindow('编辑','{:url('BackMenu/backMenuOperate',['operate'=>'edit', 'id'=>$vo.bm_id, 'pid'=>$vo.bm_pid])}','500')" >
                                                    <i class="layui-icon">&#xe642;</i>编辑
                                                </a>
                                            {/eq}
                                            {eq name="check.BackMenubackMenuDel" value="1"}
                                                <a href="javascript:;" onclick="dataDel(this,'{$vo.bm_id}')" >
                                                    <i class="layui-icon">&#xe640;</i>删除
                                                </a>
                                            {/eq}
                                        </div>
                                    </td>
                                </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /**分类展开收起的分类的逻辑*/
    common.tableVertical();
    /**删除*/
    function dataDel(obj, id){
        layer.confirm('确认要删除这条数据吗？',function(){
            var index = layer.load();
            //发异步删除数据
            $.ajax({
                type:"post",
                url:"{:url('BackMenu/backMenuDel')}",
                data:{id:id},
                dataType:'json',
                success:function (data) {
                    if(data.status === 1){
                        $(obj).parents("tr").remove();
                        layer.msg(data.info, {icon: 6,time:1500});
                    }else{
                        layer.msg(data.info, {icon: 5,time:1500});
                    }
                    layer.close(index);
                },
                error:function (data) {
                    layer.close(index);
                    layer.msg("不好意思，出现了一点问题", {icon: 5});
                }
            });
        });
    }
</script>
</html>